-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace ValueCow::as_bool with truthiness function #17
Replace ValueCow::as_bool with truthiness function #17
Conversation
Implements a truthiness function for evaluating conditionals. The following values are falsy: - None - `false` - `0` integer and `0.0` float - empty string, list, and map Everything else is truthy.
ce762f1
to
2cc52bd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think what I didn't put in the original issue #9 is that imagined the truthiness to be configurable. I think my original thoughts were that it makes template logic more robust to enforce booleans in if
statements. Although I don't have any real data to back this up, if you think this is what most people will want then I'm happy to make this the default.
I would agree that "strict" conditional evaluation can be a good thing, but the merit of that seems a bit lost on Maybe we should take this opportunity to investigate #6? In the meantime, I think it's a good idea to have this be a configurable setting, whichever the default may be. Off the top of my head, there could be a |
I think we can discuss the in a separate issue #19 . I think let's get the build passing on this change and then we can merge it like it is now. |
@lunabunn Needed this today, so I fixed the build and I'm going to merge if that's okay |
Not sure if you actually wanted this, but I felt that it could be useful for my application, so:
Implements a truthiness function for evaluating conditionals.
The following values are falsy:
false
0
integer and0.0
floatEverything else is truthy.
Closes #9. Please let me know if there is anything you would like to see changed!